Example: Monitoring Server Health Using Run for Collection (GAD)
Scenario
A company has a number of production servers which they use to host their internal applications. They want to use Ivanti Neurons for ITSM to monitor the health of these servers. The company has an external application which monitors the servers and can send a web request containing the latest information.
By leveraging the Run for Collection Quick Action, Go to Record Quick Action, and webhooks, the company can easily set up a way to take this data and record it in Neurons for ITSM.
Values are shown in this example for both JSON and XML.
Prerequisites
To use these Quick Actions, set the global constant EnableActionService to True.
This example assumes you have administrator-level access to ITSM and are familiar with creating both business objects and Quick Actions. If you do not have administrator-level access, see Notes on roles and permissions and Open the Graphical Action Designer. You also need a business object called Production Server in ITSM.
![Closed](../../../../../Skins/Default/Stylesheets/Images/transparent.gif)
Two Quick Actions need to be created: Incoming Server Status Update and Go To and Update Server Status.
1.To create the Incoming Server Status Update Quick Action, open the Graphical Action Designer.
See: Open the Graphical Action Designer.
Tip: You can use the Classic Action Designer if you prefer.
2.Drag action blocks on to the Designer Board for the Update Stored Values and Variables Quick Action and the Run for Collection Quick Action. Link the two blocks as shown.
3.Name the Composite Action as Incoming Server Status Update.
4.Select the Update Stored Values and Variables Quick Action block. This block updates the stored values and variables used in your action.
For more help see: Update Stored Values and Variables Quick Action
5. Configure the action to store the JSON or XML in the required variable WebhookBody. Enter the values as follows:
Field |
Value |
---|---|
Variable Type |
Variable |
Name |
WebhookBody |
Data Type |
JSON or XML |
Value (JSON) |
{} |
Value (XML) |
<xml></xml> |
6.Select the Run for Collection block and then create an expression using the Simplified Expression Editor. For help, see: Using the Simplified Expression Editor
The collection to step through is taken directly from the incoming data sent to the webhook. Once per item in the collection, the Go To and Update Server Status Quick Action is run.
Field | Parameter |
---|---|
Collection to step through | $(Variable("WebhookBody")) |
Action to Run for each item | Go To and Update Server Status |
Stop on Error | Not selected |
7.To create the Go To and Update Server Status Quick Action, drag blocks on to the Designer Board for the Go to Record Quick Action and Update a Record Quick Action and link together as shown.
8.Once per item in the collection, the Go to Record Quick Action, is used to go to a record where the ServerName field is equal to the value taken from the current collection item. Select the Go to Record block and enter the values:
Field |
Value |
---|---|
Field Name | ServerName (Name) |
Field Value (JSON) | $(JSONPathValue(CurrentCollectionItem(), "$.ServerName")) |
Field Value (XML) | $(XPathValue(CurrentCollectionItem(), "ServerName")) |
9.If the action doesn't find a record with that name, select the Create a new Record if not found option to create a new record, again taking the name from the current collection item.
Field |
Value |
---|---|
Create a new Record if not found | Selected |
Field Name |
ServerName (Name) |
Field Value (XML) | $(JSONPathValue(CurrentCollectionItem(), "$.ServerName")) |
Field Value (XML) | $(XPathValue(CurrentCollectionItem(), "ServerName")) |
10.Finally, the LastStatus data is taken out of the current collection item, and used to update the corresponding field on the current record. Select the Update a Record Quick Action block and select or enter the values:
Field |
Value |
---|---|
Field Name | LastStatus (Last Known Status) |
Field Value (JSON) | $(JSONPathValue(CurrentCollectionItem(), "$.LastStatus")) |
Field Value (XML) | $(XPathValue(CurrentCollectionItem(), "LastStatus")) |
![Closed](../../../../../Skins/Default/Stylesheets/Images/transparent.gif)
1.Create a webhook to trigger the Incoming Server Status Update Quick Action when data is sent to the appropriate endpoint. In the Settings menu, click on Webhooks Manager in the Build section.
The Webhooks Manager opens.
2.Click Add a Webhook.
3.Enter information into the fields:
Field | Value |
---|---|
Name | Update Server Status |
Description | Webhook for sending external server status info to ITSM |
Endpoint Extension |
UpdateServerStatus Note: The endpoint extension is case-sensitive. |
Full Endpoint |
https://{tenant url}/api/rest/Webhooks/Execute?extension=UpdateServerStatus |
Select Business Object |
ProductionServer |
Select Action |
Incoming Server Status Update (Composite Action) |
4.Click Save.
A confirmation message appears saying Webhook successfully created. Your webhook appears in the list and is enabled by default.
![Closed](../../../../../Skins/Default/Stylesheets/Images/transparent.gif)
1.Ensure you have three existing records in the system for the Production Server business object:
2.In Postman, simulate the latest data coming from the external application to send to the Update Server Status webhook in ITSM:
JSON:
[
{
"ServerName": "Authentication Server",
"LastStatus": "Crashed"
},
{
"ServerName": "Email Server",
"LastStatus": "Unresponsive"
}
{
"ServerName": "Payments Server",
"LastStatus": "Slow"
}
{
"ServerName": "Payments Server Replica",
"LastStatus": "Starting"
}
]
XML:
<xml>
<Server>
<ServerName>Authentication Server</ServerName>
<LastStatus>Crashed</LastStatus>
</Server>
<Server>
<ServerName>Email Server</ServerName>
<LastStatus>Unresponsive</LastStatus>
</Server>
<Server>
<ServerName>Payments Server</ServerName>
<LastStatus>Slow</LastStatus>
</Server>
<Server>
<ServerName>Payments Server Replica</ServerName>
<LastStatus>Starting</LastStatus>
</Server>
</xml>
For each item, the Go to RecordQuick Action and Incoming Server Status Update composite action are run. The current server status data is accessed using the CurrentCollectionItem() expression function.
For the last case, there is no record existing as yet but the Go to RecordQuick Action was configured to create one.
3.In Postman, click Send and check for status 200 OK.
4.Go back to ITSM and do a Refresh.
Every existing record is updated with the corresponding latest status, by server name. The "missing" fourth record is also created using the data as supplied.